<template>
	<view>
		<button class="zc-button-default" :disabled="DissBtn_XXX" :loading="LoadBtn_XXX"  @tap="doBtn_XXX()">{{Text_XXX}}</button>
	</view>
</template>

<script>
	let _this = this;
	export default {
		name: 'zc-button',
		props: {
			Page:{
				type:String,
				required:true
			},
			IsLogin:{
				type:String,
				default:'true'
			},
			Name:{
				type:String,
				required:true
			},
			Action:{
				type:String,
				required:true
			},
			Text:{
				type:String,
				default:'未定义'
			}
		},
		data() {
			return {
				Text_XXX:'未定义',
				Page_XXX:'',
				IsLogin_XXX:'true',
				Name_XXX:'',
				Action_XXX:'',
				Data_XXX:null,
				DissBtn_XXX:false,
				LoadBtn_XXX:false
			};
		},
		created() {
			_this = this;
			_this.Text_XXX = _this.$props.Text;
			_this.Page_XXX = _this.$props.Page;
			_this.IsLogin_XXX = _this.$props.IsLogin;
			_this.Name_XXX = _this.$props.Name;
			_this.Action_XXX = _this.$props.Action;
		},
		methods: {
			doMakeData:function(data){
				_this.Data_XXX = data;
			},
			cbBtn_XXX:function(jsonData,scope){
				_this._method_ = 'cbBtn_XXX';
				_this.__route__ = _this.Page_XXX;
				try{
					if(jsonData.state === 'back') {
						if(jsonData.success) {
							uni.showToast({
								title:'已保存'
							});
							_this.$emit('doBackData', jsonData.data);
						}
						else{
							_this.$ZcPublic.Err(jsonData.msg); 
						}
					}
					if(jsonData.state === 'end') {
						if(_this.$ZcPublic.Modal === 'false') {
							_this.LoadBtn_XXX = false;
							_this.DissBtn_XXX = false;
						}
						else{
							uni.hideLoading();
						}
					}
				}catch(e){
					_this._errmsg_ = e.message;
					_this.$ZcPublic.Server.Log(_this);
				}
			},
			doBtn_XXX:function() {
				_this._method_ = 'doBtn_XXX';
				_this.__route__ = _this.Page_XXX;
				try{
					_this.$emit('doMakeData');
					if(_this.Data_XXX) {
						if(_this.Data_XXX.success === false) {
							if(_this.Data_XXX.msg) {
								_this._method_ = _this.Data_XXX.method;
								throw Error(_this.Data_XXX.msg);
							}
							return;
						}
						if(_this.$ZcPublic.Modal === 'false') {
							_this.LoadBtn_XXX = true;
							_this.DissBtn_XXX = true;
						}
						else{
							_this.$ZcPublic.Loading('处理中');
						}
						console.log('post', _this);
						_this.$ZcPublic.Server.Post({
							IsNeedLogin: _this.IsLogin_XXX,
							Paras: {
								Name: _this.Name_XXX,
								Action: _this.Action_XXX,
								Data: _this.Data_XXX.data
							},
							Callback:_this.cbBtn_XXX,
							Scope: _this
						}); 
					}
				}
				catch(e){
					_this._errmsg_ = e.message;
					if(_this.Data_XXX && _this.Data_XXX.data){
						let dataErr = {};
						dataErr.Name = _this.Name_XXX;
						dataErr.Action = _this.Action_XXX;
						dataErr.IsLogin = _this.IsLogin_XXX;
						dataErr.Data = _this.Data_XXX.data;
						_this._data_ = JSON.stringify(dataErr);
					}
					_this.$ZcPublic.Server.Log(_this);
				}
			}
		}
	}
</script>

<style>
.zc-button-default{
	background-color: #3EA3F8;
	border-radius: 35upx;
	height: 70upx;
	line-height: 70upx;
	padding: 0 40upx;
	color:#fff;
}
/*
button[disabled]{
background-color: red !important;
}*/
</style>
